<template>
  <div>
    <h1 ref="name">{{ name }}</h1>
    <button @click="changeName" @contextmenu.prevent.stop="rightClick($event)">
      修改name
    </button>
  </div>
</template>

<script>
import { getLocalstorage, setLocalstorage } from '../../utils/local'
export default {
  data () {
    return {
      name: 'vue2'
    }
  },
  created () {
    this.name = getLocalstorage('person')
  },
  methods: {
    changeName () {
      const person = {
        name: '张三',
        age: 20
      }
      const that = this
      setLocalstorage('person', person, that)
    },
    rightClick (e) {
      console.log(e)
    }
  }
}
</script>

<style>
</style>
